// ml:run = $bin < input
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;

ll n, k, m;

struct matrix
{
    typedef long long value_type;
    typedef std::vector<value_type> row_type;

	matrix(int ro, int co)
	{
		mat.resize(ro);
        for (int i = 0; i < ro; i++)
            mat[i].resize(co);
	}

	matrix(int n)
	{
		mat.resize(n);
        for (int i = 0; i < n; i++)
            mat[i].resize(n);
		for (int i = 0; i < n; i++) mat[i][i] = 1;
	}

	matrix();

	int row() const { return mat.size(); }
	int col() const { return mat[0].size(); }

	row_type       & operator[](int x)       { return mat[x]; }
	row_type const & operator[](int x) const { return mat[x]; }

	private:
	std::vector<row_type> mat;
};

matrix operator*(matrix const & a, matrix const & b)
{
	int m = b.col();
    if (m > 1) m = n + 1;
	matrix r(n + 1, m);
	for (int i = 0; i < n + 1; i++)
		for (int j = 0; j < m; j++)
			for (int k = 0; k < n + 1; k++)
				r[i][j] = r[i][j] + (a[i][k] * b[k][j]);
	return r;
}

matrix quick_pow(matrix const & a, long long b)
{
	if (!b) return matrix(n + 1);

	matrix ret = quick_pow(a, b / 2);
	ret = ret * ret;
	if (b & 1) ret = ret * a;
	return ret;
}

struct opt { char ch; int x, y; };
opt op[200];

matrix a(200);

int main()
{
    std::ios_base::sync_with_stdio(false);
    while (std::cin >> n >> m >> k && (n || m || k)) {
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) a[i][j] = 0;
            a[i][i] = 1;
        }
        for (int i = 0, x, y; i < k; i++) {
            std::cin >> op[i].ch;
            char ch = op[i].ch;
            if (ch == 'g') {
                std::cin >> x; x--;
                op[i].x = x;
            } else if (ch == 's') {
                std::cin >> x >> y; x--; y--;
                op[i].x = x;
                op[i].y = y;
            } else if (ch == 'e') {
                std::cin >> x; x--;
                op[i].x = x;
            }
        }
        if (!m) {
            std::cout << "0";
            for (int i = 1; i < n; i++) std::cout << " 0";
            std::cout << "\n";
            continue;
        }
        for (int i = 0, x, y; i < k; i++) {
            char ch = op[i].ch;
            if (ch == 'g') {
                x = op[i].x;
                a[x][n]++;
            } else if (ch == 's') {
                x = op[i].x;
                y = op[i].y;
                std::swap(a[x], a[y]);
            } else if (ch == 'e') {
                x = op[i].x;
                for (int i = 0; i <= n; i++)
                    a[x][i] = 0;
            }
        }
        a = quick_pow(a, m);
        matrix init(n + 1, 1);
        init[n][0] = 1;
        init = a * init;
        std::cout << init[0][0];
        for (int i = 1; i < n; i++) std::cout << " " << init[i][0];
        std::cout << "\n";
    }
}

